<?php

set_time_limit(0);
/*
 *  This is NOT a freeware, use is subject to license terms
 *  @author: hzq <151680523@qq.com>

 * @version     $Id:filename.php
 */

class fengxi extends model {

    function home() {
        $list = glob(WEBDIR . '/logs/*.log');
        foreach ($list as $v) {
            $v1 = '/index.php/fengxi/add/' . my_urlencode($v);
            echo "<li><a href='$v1' target='_blank'>$v</a></li>";
        }
    }

    function add($s) {


        $file = my_urldecode($s);

        $f = fopen($file, 'r');





        while (!feof($f)) {
            $line = fgets($f);
            if (strpos($line, 'Baiduspider') || strpos($line, 'Googlebot')) {
/// type  url  times  status   ids   urltype 
                $arr = (explode(' ', $line));
                $data['times'] = str_replace('[', '', $arr[3]);
                $data['type'] = str_replace(';', '', $arr[13]);
                $data['url'] = str_replace(';', '', $arr[6]);
                $data['status'] = intval($arr[8]);
                $a = preg_split('/\/|\?|\=|\&|\-|\./', $data['url']);
                $data['urltype'] = $a[1];
                if ($a[1] == 'forum' && strpos($data['url'], 'viewthread')) {
                    $data['urltype'] = 'thread';
                    $data['ids'] = $a[6];
                } elseif ($a[1] == 'thread') {
                    $data['ids'] = $a[2];
                }

                if (strpos($line, 'Baiduspider')) {
                    $tb = 'logs_fenxi_baidu';
                } else {
                    $tb = 'logs_fenxi_google';
                }

                echo SQLS::inserts($data, $tb);
                echo '--';
            }
        }
    }

}

?>
